﻿using System.Collections.Generic;
using System.Linq;
using static CoreLims.Models.CoreLims.Reagent;

namespace CoreLims.Models.CoreLims
{
    public static class ReagentExtension
    {
        public static List<Reagents> getReagents(this Reagent reagent, CoreLimsContext dbContext) =>
            dbContext.Reagents.ToList();

        public static Reagents getReagents(this Reagent reagent, CoreLimsContext dbContext, string Id) =>
            dbContext.Reagents.Where(s => s.Id == Id).FirstOrDefault();

        public static List<Record> getRecords(this Reagent reagent, CoreLimsContext dbContext) =>
            dbContext.Record.ToList();

        public static Record getRecord(this Reagent reagent, CoreLimsContext dbContext, string Id) =>
            dbContext.Record.Where(s => s.Id == Id).FirstOrDefault();

        public static Component getComponent(this Reagent reagent, CoreLimsContext dbContext, string Id) =>
            dbContext.Component.Where(s => s.Id == Id).FirstOrDefault();

        public static List<Component> getComponentsByReagentId(this Reagent reagent, CoreLimsContext dbContext, string ReagentId) =>
           dbContext.Component.Where(s => s.ReagentId == ReagentId).ToList();

        public static List<Record> getRecordsByReagentId(this Reagent reagent, CoreLimsContext dbContext, string ReagentId) =>
           dbContext.Record.Where(s => s.ReagentId == ReagentId).ToList();

    }

}
